package com.paper.tiger.easy.rpc.core;

/**
 * [简要描述]: 服务器与客户端通信类型
 * [详细描述]:
 *
 * @author ZouHaiBo
 * @version 1.0, 2021/5/31 09:38
 * @since JDK 1.8
 */
public enum ServerType
{

    REGISTER_REQUEST(0,"注册请求","REGISTER_REQUEST"),
    REGISTER_RESPONSE(1,"注册响应","REGISTER_RESPONSE"),
    SELECT_REQUEST(2,"查询请求","SELECT_REQUEST"),
    SELECT_RESPONSE(3,"查询响应","SELECT_RESPONSE"),
    NEW_JOIN_SERVICE(4,"新加入服务","NEW_JOIN_SERVICE"),
    HEART_BEAT_REQ(5,"服务器心跳请求","HEART_BEAT_REQ"),
    HEART_BEAT_RESP(6,"服务器心跳相应","HEART_BEAT_RESP"),
    SERVER_OFF_LINE(7,"服务下线","SERVER_OFF_LINE"),

    ;

    private final int code;

    private final String desc;

    private final String registerName;



    ServerType(int code, String desc,String registerName)
    {
        this.registerName = registerName;
        this.code = code;
        this.desc = desc;
    }

    public static ServerType getByCode(Integer code) {
        if (code == null) return null;

        for (ServerType value : values())
        {
            if (value.getCode() == code){
                return value;
            }
        }
        return null;

    }


    public int getCode()
    {
        return code;
    }

    public String getDesc()
    {
        return desc;
    }

    public String getRegisterName()
    {
        return registerName;
    }
}
